<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="u" uri="/iuie-tag"%>
<%@ taglib prefix="sys" uri="/sys-tag" %>
<%@ taglib prefix="lui" tagdir="/WEB-INF/tags" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>markdown编写博客</title>
</head>
<lui:context/>
<u:View basePath="/res-datum/blog" userJS="mdBlogEdit" userCSS="mdBlogEdit" res="editor.md" delayLoadJs="false">
<body style="height: 560px;">
	<form class="m-cust" id="addBlogFrm">
		<c:if test="${not empty requestScope.blogId }">
			<lui:ajax url="${ctx }/datum/blog/mdUpdateBlog" id="addBlogAjax" formQuery="#addBlogFrm" type="post" formSubmit="true"
	    		contentType="application/x-www-form-urlencoded" onSuccess="MarkdownEditorBlogEditPage.onAddBlogSucc" htmlEncodeNames="mdContent"
	    		onError="MarkdownEditorBlogEditPage.onAddError"/>
		</c:if>
		<c:if test="${empty requestScope.blogId }">
	    	<lui:ajax url="${ctx }/datum/blog/mdAddBlog" id="addBlogAjax" formQuery="#addBlogFrm" type="post" formSubmit="true"
	    		contentType="application/x-www-form-urlencoded" onSuccess="MarkdownEditorBlogEditPage.onAddBlogSucc" htmlEncodeNames="mdContent"
	    		onError="MarkdownEditorBlogEditPage.onAddError"/>
		</c:if>
        <table id='blogInfo' class='t-blog-info'>
        	<tr>
        		<td style="width: 75px;">博客类型</td>
        		<td>
        		    <%-- <input name="blogId" hidden="hidden" value="${requestScope.blogId}" id="blogId"> --%>
        			<input name='blogType.codeInfoValue' hidden='hidden' value='${requestScope.blogTypeId}'>
        			<span style='text-decoration: underline;color: #D00;' id='blogTypeName'><c:out value="${requestScope.blogTypeName}"></c:out></span>
        		</td>
        		<td style='width:75px;'>
	        		<a href="javascript:void(0)" style='text-decoration: underline;' onclick="MarkdownEditorBlogEditPage.openSwitchBlogTypeDialog()">更改</a>
	        	</td>
	        	<td style='width:75px;'>
	        		<a href="javascript:void(0)" style='text-decoration: underline;' onclick="MarkdownEditorBlogEditPage.openAddDescDialog()">编辑概述</a>
        		</td>
	        	<td style='width:75px;'>
	        		<a href="javascript:void(0)" style='text-decoration: underline;' onclick="MarkdownEditorBlogEditPage.openBindBookDialog()">绑定书籍</a>
        		</td>
        	</tr>
        	<tr>
        		<td colspan="5"><input name="blogName" autofocus="autofocus" id="blogName" type="text" class='t-mdeditor-title' placeholder="在这儿输入标题"
	      				data-validate='true' data-not-empty='true' data-empty-text="标题不能为空" maxlength="200"></td>
        	</tr>
        </table>
        <div class="form-group m-narrow row">
        	<div class="col-xs-12">
				<lui:mdeditor nameEditor="mdContent" nameHtml="htmlContent" id="articleEditor" width="80%" height="460" emoji="true"/>
            </div>
        </div>
        <input type='hidden' name='fileInfo.fileId' id='fileId'>
		<input type='hidden' name='blogId'  id="blogId">
		<input type='hidden' name='blogAttr' value="1">
		<textarea rows="" cols="" hidden="hidden" name='remarks'></textarea>
		<c:if test="${not empty requestScope.blogId }">
			<lui:ajax url="${ctx }/datum/blog/findById/${requestScope.blogId }" id="findBlogByIdAjax" 
				onSuccess="MarkdownEditorBlogEditPage.findBlogByIdSucc" autoSend="true"/>
    	</c:if>
	</form>
	<lui:dialogFooter>
		<button class="btn btn-primary m-btn" type="button" onclick="MarkdownEditorBlogEditPage.saveBlog()">保存</button>
	    <button class="btn btn-default m-btn" type="button" onclick="MarkdownEditorBlogEditPage.closeEditor()" data-dismiss="dialog-box">关闭</button>
	</lui:dialogFooter>
</body>
</u:View>
</html>